﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var auditData = Jxstar.findComboData('audit');
	var yesnoData = Jxstar.findComboData('yesno');

	var cols = [
	{col:{header:'记录状态', width:83, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: auditData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: auditData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'contract_mpay__auditing',type:'string'}},
	{col:{header:'实施单位', width:190, sortable:true}, field:{name:'contract_mpay__dept_name',type:'string'}},
	{col:{header:'支付月份', width:100, sortable:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m') : '';
		}}, field:{name:'contract_mpay__pay_month',type:'date'}},
	{col:{header:'计划付款(万元)', width:105, sortable:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract_mpay__plan_money',type:'float'}},
	{col:{header:'核准付款(万元)', width:100, sortable:true, align:'right',renderer:JxUtil.formatNumber(6)}, field:{name:'contract_mpay__check_money',type:'float'}},
	{col:{header:'合同数量', width:100, sortable:true, align:'right',renderer:JxUtil.formatInt()}, field:{name:'contract_mpay__pay_num',type:'int'}},
	{col:{header:'申请日期', width:100, sortable:true, align:'center',
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'contract_mpay__app_date',type:'date'}},
	{col:{header:'申请人', width:100, sortable:true}, field:{name:'contract_mpay__app_user',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'contract_mpay__mpay_id',type:'string'}},
	{col:{header:'实施单位ID', width:100, sortable:true, hidden:true}, field:{name:'contract_mpay__dept_id',type:'string'}},
	{col:{header:'是否信息类', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'contract_mpay__is_info',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'pay_mplan'
	};
	
	
	config.eventcfg = {		//汇总付款计划		statPlan: function(){			var records = this.grid.getSelectionModel().getSelections();			if (!JxUtil.selectone(records)) return;			if (this.checkAudit()) return;			if(records[0].get('contract_mpay__mpay_id') == ""){					JxHint.alert('请先保存数据！');					return;			}			var self = this;			var hdcall = function() {				var key = records[0].get('contract_mpay__mpay_id');				var params = 'funid=pay_mplan&keyid='+ key +'&pagetype=editgrid&eventcode=statPlan';								var endcall = function(data) {					self.grid.getStore().reload();					JxHint.alert('请查看付款计划明细！');				};				//发送请求				Request.postRequest(params, endcall);			};						//确定执行当前操作吗？			Ext.Msg.confirm(jx.base.hint, jx.event.doyes, function(btn) {				if (btn == 'yes') hdcall();			});		},				//创建月度付款计划		createPlan: function(form) {						var params = 'funid=pay_mplan' + JxUtil.getFormValues(form, false);			params += '&pagetype=editgrid&eventcode=createPlan';						var self = this;			var endcall = function(data) {				//重新加载数据				self.grid.getStore().reload();			};			//发送请求			Request.postRequest(params, endcall);		},				//创建付款计划对话框		showPlan: function() {			var isInfoData = Jxstar.findComboData('yesno');					var printForm = new Ext.form.FormPanel({				id: 'node_pay_mplan_form1',				style: 'padding:5px;',				border: false,				frame: false,				baseCls: 'x-plain',				items: [{					anchor:'100%',					border: false,					layout:'column',					autoHeight:true,					items:[{						border:false,						columnWidth:0.5,						layout:'form',						style: 'padding-left:10px;',						items:[							{xtype:'trigger', fieldLabel:'实施单位', name:'contract_mpay__dept_name', defaultval:'fun_getOrgName()',								anchor:'100%', triggerClass:'x-form-search-trigger',								maxLength:50, allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', editable:false,								onTriggerClick: function() {									if (this.menu == null) {										var selcfg = {pageType:'combogrid', nodeId:'sys_dept1', layoutPage:'', sourceField:'sys_dept.dept_name;dept_id', targetField:'contract_mpay.dept_name;dept_id', whereSql:" ( dept_level = 1 or dept_id ='10040029' )", whereValue:'', whereType:'', isSame:'0', isShowData:'1', isMoreSelect:'0',isReadonly:'1',fieldName:'contract_mpay.dept_name'};										this.menu = Jxstar.createComboMenu(this);										JxSelect.createComboGrid(selcfg, this.menu, 'node_pay_mplan_form1');									}									this.menu.show(this.el);								}},							{xtype:'textfield', fieldLabel:'申请人', name:'contract_mpay__app_user', defaultval:'fun_getUserName()', readOnly:true, anchor:'100%', maxLength:20},							{xtype:'combo', fieldLabel:'是否信息类', name:'contract_mpay__is_info', defaultval:'', readOnly:false, 								anchor:'100%', editable:false, allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*',								store: new Ext.data.SimpleStore({									fields:['value','text'],									data: isInfoData								}),								emptyText: jx.star.select,								mode: 'local',								triggerAction: 'all',								valueField: 'value',								displayField: 'text'},							{xtype:'hidden', fieldLabel:'实施单位ID', name:'contract_mpay__dept_id', defaultval:'fun_getOrgId()', anchor:'100%'}						]					},{						border:false,						columnWidth:0.5,						layout:'form',						style: 'padding-left:10px;',						items:[							{xtype:'datefield', fieldLabel:'支付月份', name:'contract_mpay__pay_month', defaultval:'fun_getCurMonth(1)', format:'Y-m', allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%'},							{xtype:'datefield', fieldLabel:'申请日期', name:'contract_mpay__app_date', defaultval:'fun_getToday()', format:'Y-m-d', allowBlank:false, labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%'}						]					}					]				}]			});						//烟厂项目部特殊处理			var deptId = '';			var deptName = JxDefault.getDeptName();			if (deptName == '许昌卷烟厂易地技改项目部') {//getDeptName getDeptId				deptId = JxDefault.getDeptId();			} else {				deptId = JxDefault.getOrgId();				deptName = JxDefault.getOrgName();			}						//添加缺省值			var form = printForm.getForm();			form.set('contract_mpay__dept_name', deptName);			form.set('contract_mpay__dept_id', deptId);			form.set('contract_mpay__app_date', JxDefault.getToday());			form.set('contract_mpay__pay_month', JxDefault.getCurMonth(1));			form.set('contract_mpay__app_user', JxDefault.getUserName());						var self = this;			//创建对话框			var win = new Ext.Window({				title:	'创建月度付款计划',				layout:'fit',				width:520,				height:170,				resizable: false,				modal: true,				closeAction:'close',				items:[printForm],				buttons: [{					text:jx.base.ok,		//'确定'					handler:function(){						//数据校验						if (!form.isValid()) {							JxHint.alert(jx.event.datavalid);	//'请确保输入的数据正确完整！'							return;						}						self.createPlan(form);						win.close();					}				},{					text:jx.base.cancel,	//'取消'					handler:function(){win.close();}				}]			});			win.show();		},						//链接 月度付款计划汇总 功能		planstat1: function() {			Jxstar.createNode('sum_pay_plan');		},		//链接 付款完成情况统计 功能		planstat2: function() {			Jxstar.createNode('sum_pay_done');		}	};
		
	return new Jxstar.GridNode(config);
}